package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.ProductTag;

import java.util.List;

@Mapper
public interface ProductTagMapper {
    @Select("SELECT * FROM product_tag WHERE product_id = #{productId}")
    List<ProductTag> findByProductId(Long productId);

    @Insert("INSERT INTO product_tag(product_id, tag_name) VALUES(#{productId}, #{tagName})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(ProductTag tag);

    @Delete("DELETE FROM product_tag WHERE product_id = #{productId} AND tag_name = #{tagName}")
    void delete(ProductTag tag);
}